package net.airuima.service;

import net.airuima.domain.Demo;
import net.airuima.repository.DemoRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Copyright (C), 2017-2023, 武汉睿码智能科技有限公司
 * Service
 *
 * @author ruima
 * @date 2024-02-06
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DemoService extends CommonJpaService<Demo> {

    private final Logger log = LoggerFactory.getLogger(DemoService.class);

    private final DemoRepository demoRepository;

    public DemoService(DemoRepository demoRepository) {
        this.demoRepository = demoRepository;
    }

    @Override
    @Transactional(readOnly = true)
    public Page<Demo> find(Specification<Demo> spec, Pageable pageable) {
        return demoRepository.findAll(spec, pageable);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Demo> find(Specification<Demo> spec) {
        return demoRepository.findAll(spec);
    }

    @Override
    @Transactional(readOnly = true)
    public Page<Demo> findAll(Pageable pageable) {
        return demoRepository.findAll(pageable);
    }

}
